<div class="am-u-sm-12">
        <form class="am-form" id="list-form" action="${base}/product/list" method="post">
            <input type="hidden" id="keywords" name="keywords" value='${keywords!""}' />
            <table class="am-table am-table-bordered am-table-radius table-main" style="padding:0;">
                <tbody>
                    <tr>
                        <th class="am-text-middle">所属机构</th>
                        <td >
                            <div class="am-u-sm-10">
                                <select id="org" name="org" data-am-selected="{btnSize: 'sm',maxHeight: 200,searchBox: 1}">
                                    <option value="-1" 
                                        <%if (isEmpty(org)||org=="-1"){%>
                                           selected = "selected"
                                        <%}%>
                                    >所有</option>
                                    
                                    <%for(o in orgs!){%>
                                        <option value="${o.value}" 
                                        <%if (!isEmpty(org)&&org==o.value){%>
                                           selected = "selected"
                                        <%}%>
                                        >${o.key}</option>
                                    <%}%>
                                </select>
                            </div>
                        </td>
                        <th class="am-text-middle">所属品牌</th>
                        <td>
                            <div class="am-u-sm-10">
                                <select id="brand" name="brand" data-am-selected="{btnSize: 'sm',maxHeight: 200,searchBox: 1}">
                                    <option value="-1" 
                                        <%if (isEmpty(brand)||brand=="-1"){%>
                                           selected = "selected"
                                        <%}%>
                                    >所有</option>
                                    
                                    <%for(b in brands!){%>
                                        <option value="${b.id}" 
                                        <%if (!isEmpty(brand)&&brand==b.id+""){%>
                                           selected = "selected"
                                        <%}%>
                                        >${b.name}</option>
                                    <%}%>
                                </select>
                            </div>
                        </td>
                    </tr>
                    
                    <tr>
                        <th class="am-text-middle">名称</th>
                        <td>
                            <div class="am-u-sm-10">
                              <input type="text" id="name" style="width:200px;" class="am-form-field am-input-sm" value="${name!}" />
                            </div>
                        </td>
                        <th class="am-text-middle">是否启用</th>
                        <td>
                            <div class="am-u-sm-10">
                                <select id="enabled" name="enabled" data-am-selected="{btnSize: 'sm',maxHeight: 200}">
                                    <option value="-1"  <%if((!has(enabled))||(enabled! == "-1")) {%>
                                     selected
                                     <%}%>
                                     >全部</option>
                                    <option value="1" <%if(enabled! == "1") {%>
                                    selected
                                    <%}%>
                                     >启用</option>
                                    <option value="0" <%if(enabled! == "0") {%>
                                    selected
                                    <%}%>
                                    >禁用</option>
                                </select>
                            </div>
                        </td>
                    </tr>
                    
                    <tr>
                        <td colspan="4">
                            <div align='right'>
                                <button type="button" class="am-btn am-btn-default am-btn-sm am-text-secondary" id="submit-btn">搜索</button>
                                <button type="button" class="am-btn am-btn-default am-btn-sm am-text-secondary" id="export-btn">导出</button>
                            </div>
                        </td>
                    </tr>
                </tbody>
            </table>
        </form>
    </div>
    
  
  <script type="text/javascript">
    $(function(){
      
      //将所有的搜索条件放到keywords
      function keywords(){
        var keywordsObj = {};
        if($("#name").val())
          keywordsObj.name = $("#name").val();
        if($("#brand").val())
          keywordsObj.brand = $("#brand").val();
        if($("#category").val())
          keywordsObj.category = $("#category").val();
        if($("#org").val())
          keywordsObj.org = $("#org").val();
        if($("#enabled").val()!=-1)
             keywordsObj.enabled = $("#enabled").val();
             
        var keywords = "";
        if(!$.isEmptyObject(keywordsObj)){
          keywords = JSON.stringify(keywordsObj);
        }
        console.log("keywords = "+ keywords);

        $("#keywords").val(keywords);
      }
      
      
      $("#submit-btn").on("click",function(){
        keywords();
        $("#list-form").attr("action","${base}/product/list");
        $("#list-form").submit();
      });
      
      $("#export-btn").on("click",function(){
        keywords();
        $("#list-form").attr("action","${base}/product/export");
        $("#list-form").submit();
      });
    });
 
  </script>